package com.heima.common.SnowFalke;

import com.heima.utils.common.SnowflakeIdWorker;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Reference
public class IdWorkerConfig {

    @Value("${leadnews.worker-id}")
    private Long workerId;

    @Value("${leadnews.datacenter-id}")
    private Long datacenterId;

    @Bean
    public SnowflakeIdWorker snowflakeIdWorker() {
        return new SnowflakeIdWorker(workerId, datacenterId);
    }
}